package com.edu.xk.webservice;

import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.edu.xk.model.User;
import com.wordnik.swagger.annotations.Api;
import com.wordnik.swagger.annotations.ApiOperation;
import com.wordnik.swagger.annotations.ApiParam;

import net.sf.json.JSONObject;

/**
 * @moudle: WebServiceForCSS
 * @version:v1.0
 * @Description: TODO
 * @author: xukai
 * @date: 2016年12月1日 下午5:37:30
 *
 */
@Controller
@RequestMapping(value = "/user2", produces = {"application/json;charset=UTF-8"})
@Api(value = "/user", description = "群组的相关操作")
public class WebServiceForCSS {

	@ResponseBody
	@RequestMapping(value = "getUserById", method = RequestMethod.GET, produces = {"application/json; charset=utf-8","application/xml"})
	@ApiOperation(value = "通过ID查询USER信息", httpMethod = "GET", notes = "暂无")
	public String getUserById(
			@ApiParam(required = true, name = "id", value = "ID") 
			@RequestParam(value = "id") String id,HttpServletRequest request) {
		User user = new User();
		user.setId(id);
		user.setName("测试人员");
		user.setAge(25);
		JSONObject object = JSONObject.fromObject(user);
		return object.toString();
	}
	
	@ResponseBody
	@RequestMapping(value = "putUserById", method = RequestMethod.PUT, produces = {"application/json; charset=utf-8","application/xml"})
	@ApiOperation(value = "通过ID查询USER信息", httpMethod = "PUT", notes = "暂无")
	public String putUserById(
			@ApiParam(required = true, name = "id", value = "ID") 
			@RequestParam(value = "id") String id,HttpServletRequest request) {
		User user = new User();
		user.setId(id);
		user.setName("测试人员");
		user.setAge(25);
		JSONObject object = JSONObject.fromObject(user);
		return object.toString();
	}
	
	
	@ResponseBody
	@RequestMapping(value = "postUserById", method = RequestMethod.POST, produces = {"application/json; charset=utf-8","application/xml"})
	@ApiOperation(value = "通过ID查询USER信息", httpMethod = "POST", notes = "暂无")
	public String postUserById(
			@ApiParam(required = true, name = "id", value = "ID") 
			@RequestParam(value = "id") String id,HttpServletRequest request) {
		User user = new User();
		user.setId(id);
		user.setName("测试人员");
		user.setAge(25);
		JSONObject object = JSONObject.fromObject(user);
		return object.toString();
	}
	
	@ResponseBody
	@RequestMapping(value = "delUserById", method = RequestMethod.DELETE, produces = {"application/json; charset=utf-8","application/xml"})
	@ApiOperation(value = "通过ID查询USER信息", httpMethod = "DELETE", notes = "暂无")
	public String delUserById(
			@ApiParam(required = true, name = "id", value = "ID") 
			@RequestParam(value = "id") String id,HttpServletRequest request) {
		User user = new User();
		user.setId(id);
		user.setName("测试人员");
		user.setAge(25);
		JSONObject object = JSONObject.fromObject(user);
		return object.toString();
	}
	
	@ResponseBody
	@RequestMapping(value = "headUserById", method = RequestMethod.HEAD, produces = {"application/json; charset=utf-8","application/xml"})
	@ApiOperation(value = "通过ID查询USER信息", httpMethod = "HEAD", notes = "暂无")
	public String headUserById(
			@ApiParam(required = true, name = "id", value = "ID") 
			@RequestParam(value = "id") String id,HttpServletRequest request) {
		User user = new User();
		user.setId(id);
		user.setName("测试人员");
		user.setAge(25);
		JSONObject object = JSONObject.fromObject(user);
		return object.toString();
	}
}
